<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center registerPage_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub registerPage_fd0_0'>
          <!-- <view class='flex flex-wrap align-center registerPage_fd0_0_c0' @tap.stop="handleJumpDiy"
            data-type="redirectTo" data-url="/pages/tabBar/passwordLogin/passwordLogin">
            <text class='fu-iconfont2  registerPage_fd0_0_c0_c0'>&#xE794;</text>
          </view> -->
          <view class='flex flex-wrap align-stretch justify-center'>
          </view>
          <view class='flex flex-wrap align-center justify-end registerPage_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout registerPage_flex_1">
        <view class='flex flex-wrap align-center justify-center registerPage_fd1_0'>
          <image class='registerPage_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"1.png"'></image>
        </view>
        <view class='flex flex-wrap align-center passwordLogin_fd1_1'>
          <view>
            <benben-flex-tabs class-name='passwordLogin_benbenTabsfd1_1_c0' v-model="type" ref="benben_tabsfd1_1_c0"
              select-mark="benben_tabsfd1_1_c0" key="benben_tabsfd1_1_c0" :open-title-type='false' :open-sticky='true'
              :top='0' :is-show-content='false' :scrollspy='false' :tabs-info.sync="tabsInfofd1_1_c0">

              <scroll-view @scroll="tabsInfofd1_1_c0.scrollX = $event.detail.scrollLeft" id="benben_tabsfd1_1_c0"
                class="benben-tabs" style="width:600rpx" :scroll-x="true" :scroll-left.sync="tabsInfofd1_1_c0.moveX"
                scroll-with-animation="all .3s ease">
                <view class="benben-tabs-content" id="benben_tabsfd1_1_c0-content">
                  <view id="benben_tabsfd1_1_c0-title" class="benben-tabs-title flex flex align-center justify-around">
                    <view :class="{ 'checkTitlefd1_1_c0': type == '1', 'flex flex-wrap align-center': true }"
                      @tap="type = '1'" :id="`benben_tabsfd1_1_c0-title-item-${'1'}`">

                      <text>Signup with Emai</text>

                    </view>
                    <view :class="{ 'checkTitlefd1_1_c0': type == '2', 'flex flex-wrap align-center': true }"
                      @tap="type = '2'" :id="`benben_tabsfd1_1_c0-title-item-${'2'}`">

                      <text>Signup with Phone</text>

                    </view>
                  </view>
                  <view :style="{ left: tabsInfofd1_1_c0.lineleft, maxWidth: tabsInfofd1_1_c0.lineWidth ,}"
                    id="benben_tabsfd1_1_c0-line"
                    class="benben-tabs-line flex benben-flex-tabs-line passwordLogin_linefd1_1_c0"></view>
                </view>
              </scroll-view>

            </benben-flex-tabs>

          </view>
        </view>
        <view class='flex flex-wrap align-center registerPage_fd1_1' v-if=" type=='1'">
          <image class='registerPage_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"59.png"'></image>
          <benben-input class='flex-sub registerPage_fd1_1_c1' type="text" :placeholder="`Enter your phone email`"
            confirm-type="done" :maxlength="-1" placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx"
            v-model="email" />
        </view>
        <view class='flex flex-wrap align-center registerPage_fd1_1' v-if=" type=='2'">
          <image class='registerPage_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"55.png"'></image>
          <view class='flex flex-wrap align-center registerPage_fd1_2_c1' @click.stop="pickerDiy1704874099380=true">
            <text class='registerPage_fd1_2_c1_c0'>+{{area_code}}</text>
            <image class='registerPage_fd1_2_c1_c1' mode="aspectFit" :src='STATIC_URL+"56.png"'></image>
          </view>
          <benben-input class='flex-sub registerPage_fd1_1_c1' type="number" :placeholder="`Enter your phone number`"
            confirm-type="done" :maxlength="11" placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx"
            v-model="mobile" />
        </view>
        <view class='flex flex-wrap align-center registerPage_fd1_3' v-if=" type=='1'">
          <image class='registerPage_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"57.png"'></image>
          <benben-input class='flex-sub registerPage_fd1_1_c1' type="number" :placeholder="`send`" confirm-type="done"
            :maxlength="4" placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx" v-model="code" />
          <benben-send-verification-code key='1704163730005' ref="vCode1704163730005" class=' registerPage_fd1_3_c2'
            after-text='Reacquire after' before-text='send' emptye-text='Enter your phone email'
            validate-text='Enter your phone email' account-type='email' :auto='true' type='1'
            :phone="email"></benben-send-verification-code>
        </view>
        <view class='flex flex-wrap align-center registerPage_fd1_3' v-if=" type=='2'">
          <image class='registerPage_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"57.png"'></image>
          <benben-input class='flex-sub registerPage_fd1_1_c1' type="number" :placeholder="`send`" confirm-type="done"
            :maxlength="4" placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx" v-model="code" />
          <benben-send-verification-code key='1704160102988' ref="vCode1704160102988" class=' registerPage_fd1_3_c2'
            :areacode="area_code" after-text='Reacquire after' before-text='send' emptye-text='Enter your phone number'
            validate-text='Enter your phone number' account-type='phone' :auto='true' type='1'
            :phone="mobile"></benben-send-verification-code>
        </view>
        <view class='flex flex-wrap align-center registerPage_fd1_3'>
          <image class='registerPage_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"58.png"'></image>
          <benben-flex-password-diy v-model="password" class-name="flex flex align-center registerPage_fd1_5_c1"
            :placeholder="'Password'" :maxlength="12" :default-type='true'
            placeholder-style="color:#999;font-size:28rpx">
            <template #show>
              <text class='fu-iconfont2  registerPage_fd1_5_c1_icon1' data-type="show">&#xE837;</text>
            </template>
            <template #hide>
              <text class='fu-iconfont2  registerPage_fd1_5_c1_icon2' data-type="hide">&#xEBCC;</text>
            </template>
          </benben-flex-password-diy>
        </view>
        <view class='flex flex-wrap align-center registerPage_fd1_6'>
          <button class='registerPage_fd1_6_c0' v-if=" type=='2'"
            :class="mobile&&password &&code&&  is_tick ? 'active' : ''" @tap.stop="validationRegistrationFunc()">Sign
            up</button>
          <button class='registerPage_fd1_6_c0' v-if=" type=='1'"
            :class="email&&password &&code&&  is_tick ? 'active' : ''" @tap.stop="validationRegistrationFunc()">Sign
            up</button>
        </view>
        <view class='flex flex-wrap align-center justify-center registerPage_fd1_7'>
          <text class='registerPage_fd1_7_c0'>Already have an account！</text>
          <text class='registerPage_fd1_7_c1' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/tabBar/passwordLogin/passwordLogin`">Log in</text>
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex registerPage_flex_2s">
        <view class='flex flex-wrap align-center justify-center flex-sub'>
          <benben-flex-switch-new class-name='flex flex registerPage_fd2_0_c0' v-model="is_tick" :disabled='false'
            :auto='true'>
            <template v-slot:checked>

              <view class='flex flex position-relative align-center'>
                <image class='registerPage_checkfd2_0_c0_c0_c0' mode="aspectFit" :src='STATIC_URL+"7.png"'></image>
              </view>

            </template>
            <template v-slot:unchecked>

              <view class='flex flex position-relative justify-end align-center'>
                <image class='registerPage_noCheckfd2_0_c0_c1_c0' mode="aspectFit" :src='STATIC_URL+"112.png"'></image>
              </view>

            </template>
          </benben-flex-switch-new>
          <text class='registerPage_fd2_0_c1'>lagree to receive text message</text>
          <!-- <text class='registerPage_fd2_0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/dlzc/agreements/agreements`">《Terms》</text>
          <text class='registerPage_fd2_0_c1'>and </text>
          <text class='registerPage_fd2_0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/dlzc/privacyPolicy/privacyPolicy`">《Privacy Policy》</text> -->
        </view>

      </view>
      <view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex registerPage_flex_2">
        <view class='flex flex-wrap align-center justify-center flex-sub'>
          <benben-flex-switch-new class-name='flex flex registerPage_fd2_0_c0' v-model="is_tick" :disabled='false'
            :auto='true'>
            <template v-slot:checked>

              <view class='flex flex position-relative align-center'>
                <image class='registerPage_checkfd2_0_c0_c0_c0' mode="aspectFit" :src='STATIC_URL+"7.png"'></image>
              </view>

            </template>
            <template v-slot:unchecked>

              <view class='flex flex position-relative justify-end align-center'>
                <image class='registerPage_noCheckfd2_0_c0_c1_c0' mode="aspectFit" :src='STATIC_URL+"112.png"'></image>
              </view>

            </template>
          </benben-flex-switch-new>
          <text class='registerPage_fd2_0_c1'>I agree with the</text>
          <text class='registerPage_fd2_0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/dlzc/agreements/agreements`">《Terms》</text>
          <text class='registerPage_fd2_0_c1'>and </text>
          <text class='registerPage_fd2_0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/dlzc/privacyPolicy/privacyPolicy`">《Privacy Policy》</text>
        </view>

      </view>
      <view :style="{height: '88rpx'}"></view>


    </view>
    <benben-picker ref="benbenWritePickerCodepicker2" :visible.sync="pickerDiy1704874099380" :value.sync='area_code'
      :options='areaList' mode='selector' :mask-show='true' :timeout='true' :picker-height='88' default-type='area_code'
      :default-props='{"label":"area_name","value":"area_code"}'>
      <template #picker-header>
        <view class='flex flex-wrap align-center justify-between myProfile_picker2_0'>
          <text class='myProfile_picker2_0_c0' @tap="$refs.benbenWritePickerCodepicker2.cancel()">取消</text>
          <text>选择区号</text>
          <text class='myProfile_picker2_0_c2' @tap="$refs.benbenWritePickerCodepicker2.pickerConfirm()">确认</text>
        </view>
      </template>
    </benben-picker>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js';
  // 腾讯IM
  import {
    TUIChatKit,
    genTestUserSig
  } from "@/TUIKit";
  import {
    SYSTEM_CONFIG,
    SDKAppID,
    secretKey
  } from "@/common/config.js";
  import {
    vueVersion
  } from "@/TUIKit/adapter-vue";
  import {
    TUILogin
  } from "@tencentcloud/tui-core";
  // edddddddddd

  export default {
    components: {},


    data() {
      return {
        pickerDiy1704874099380: false,
        areaList: [],
        "tabsInfofd1_1_c0": {
          lineleft: '',
          lineWidth: '',
          moveX: 0,
          scrollX: 0,
          PageScrollX: 0
        },
        area_code: '',
        "mobile": "",
        "code": "",
        "password": "",
        "email": "",
        "data": {
          "userinfo": {
            "user_token": "",
            "id": "",
            "avatar": "",
            "real_name": "",
            "nickname": "",
            "email": "",
            "gender": "",
            "mobile": "",
            "birthday": ""
          }
        },
        "is_tick": false,
        "type": "2"
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      let {
        type
      } = options
      if (type !== undefined) this.type = type
      this.getArea()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      getArea() {
        this.$api.post(global.apiUrls.post65e6e32934885).then(res => {
          if (res.data.code == 1) {
            this.areaList = res.data.data
            this.area_code = this.areaList[0].area_code
          }
        })
      },
      // 聊天登录
      tUILogin(config) {
        const userSig = genTestUserSig(config).userSig;
        TUILogin.login({
          SDKAppID: config.SDKAppID,
          userID: config.userID,
          userSig: userSig,
          // 如果您需要发送图片、语音、视频、文件等富媒体消息，请设置为 true
          useUploadPlugin: true,
          useProfanityFilterPlugin: false,
          framework: `vue${vueVersion}` // 当前开发使用框架 vue2 / vue3
        }).then(() => {
          console.log('登录成功')
          TUILogin.chat.updateMyProfile({
            nick: global.userInfo.userinfo.nickname,
            avatar: global.userInfo.userinfo.avatar,
          }).then(() => {
            console.log('gengxin 成功')
          })

        })
      },
      // 聊天登录s
      //效验注册
      async validationRegistrationFunc() {
        if (this.type == '1') {
          if (!validate(this.email, 'require')) {
            this.$message.info('邮箱号不能为空');
            return false;
          }
          if (!validate(this.email, 'emailzh')) {
            this.$message.info('请输入正确的邮箱号');
            return false;
          }
        } else if (this.type == '2') {
          if (!validate(this.mobile, 'require')) {
            this.$message.info('手机号不能为空');
            return false;
          }
          // if (!validate(this.mobile, 'phone')) {
          //   this.$message.info('请输入正确的手机号');
          //   return false;
          // }
        }
        if (!validate(this.code, 'require')) {
          this.$message.info('验证码不能为空');
          return false;
        }
        if (!validate(this.code, 'captcha')) {
          this.$message.info('请输入正确的验证码');
          return false;
        }
        if (!validate(this.password, 'require')) {
          this.$message.info('密码不能为空');
          return false;
        }
        if (!validate(this.password, 'password')) {
          this.$message.info('请输入密码(6~12位字母+数字)');
          return false;
        }
        if (this.is_tick === false) {
          this.$message.info('请勾选用户协议');
          return false;
        }
        //请求方法
        //数据验证

        let datadata = await this.$api.post(global.apiUrls.post5cad9f63e4f94, {
          mobile: this.mobile,
          code: this.code,
          password: this.password,
          email: this.email,
          area_code: this.area_code
        });

        if (datadata.data.code != 1) {
          this.$message.info(datadata.data.msg);
          return
        }
        let infodata = datadata.data;
        this.data = infodata.data

        this.$store.commit('saveToken', this.data.userinfo.user_token)
        this.$store.commit('updateUserInfo', this.data)
        console.log('this.data', this.data)
        const userID = this.data.userinfo ? this.data.userinfo.id.toString() : '';
        const config = {
          userID: userID, //User ID
          SDKAppID: SDKAppID, // Your SDKAppID
          secretKey: secretKey, // Your secretKey
        };
        this.tUILogin(config)
        setTimeout(() => {
          // 延迟800ms后返回
          this.$urouter.navigateTo(`/pages/dlzc/addSchool/addSchool?into=reg`);
        }, 800);

      }
    }
  };
</script>
<style lang="scss" scoped>
  .passwordLogin_fd1_1 {
    margin: 0rpx 0rpx 64rpx 0rpx;
  }

  .passwordLogin_linefd1_1_c0 {
    background: rgba(100, 80, 235, 1);
    width: 80rpx;
    height: 6rpx;
    top: 80rpx;
    background-size: 100% auto !important;
  }

  ::v-deep .passwordLogin_benbenTabsfd1_1_c0 {
    width: 630rpx;
    height: 90rpx;
    white-space: nowrap;
    text-align: center;
    font-size: 32rpx;
    font-weight: 400;
    color: #999999;
  }

  .checkTitlefd1_1_c0 {
    font-weight: 700 !important;
    font-size: 32rpx !important;
    color: #333333 !important;
  }

  .myProfile_picker2_0_c2 {
    color: rgba(100, 80, 235, 1);
  }

  .myProfile_picker2_0_c0 {
    color: var(--benbenFontColor2);
  }

  .myProfile_picker2_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
    border-radius: 25rpx 25rpx 0rpx 0rpx;
    background-size: 100% auto !important;
  }

  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: url(image-path('54.png')) no-repeat;
    background-size: 100% auto;
  }

  .registerPage_flex_0 {
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
  }

  .registerPage_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .registerPage_fd0_0_c0 {
    width: 120rpx;
  }

  .registerPage_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .registerPage_flex_1 {
    padding: 0rpx 56rpx 0rpx 56rpx;
  }

  .registerPage_fd1_7_c1 {
    color: #6450EB;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 34rpx;
  }

  .registerPage_fd1_7_c0 {
    color: rgba(153, 153, 153, 1);
    font-size: 28rpx;
    font-weight: 400;
    line-height: 34rpx;
  }

  .registerPage_fd1_7 {
    margin: 32rpx 0rpx 0rpx 0rpx;
  }

  .registerPage_fd1_6_c0 {
    background: #EEEEEE;
    border-radius: 44rpx;
    width: 638rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;

    &.active {
      background: rgba(100, 80, 235, 1);
    }
  }

  .registerPage_fd1_6 {
    margin: 78rpx 0rpx 0rpx 0rpx;
  }

  .registerPage_fd1_5_c1_icon2 {
    width: 88rpx;
    line-height: 88rpx;
    text-align: center;
    font-size: 40rpx;
  }

  .registerPage_fd1_5_c1_icon1 {
    text-align: center;
    font-size: 34rpx;
  }

  ::v-deep .registerPage_fd1_5_c1 {
    width: 501rpx;
    font-size: 28rpx;
    height: 32rpx;
    color: rgba(23, 26, 38, 1);
  }

  .registerPage_fd1_3_c2 {
    line-height: 32rpx;
    text-align: center;
    font-size: 28rpx;
    color: rgba(23, 26, 38, 1);
    margin: 0rpx 0rpx 0rpx auto;
  }

  .registerPage_fd1_3 {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0rpx 3rpx 6rpx 1rpx #F2F5FF;
    background-size: 100% auto;
    border-radius: 44rpx;
    padding: 24rpx 32rpx 24rpx 32rpx;
    margin: 32rpx 0rpx 0rpx 0rpx;
  }

  .registerPage_fd1_2_c1_c1 {
    width: 14rpx;
    height: 8rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .registerPage_fd1_2_c1_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 34rpx;
    margin: 0rpx 10rpx 0rpx 0rpx;
  }

  .registerPage_fd1_2_c1 {
    margin: 0rpx 24rpx 0rpx 0rpx;
  }

  .registerPage_fd1_1_c1 {
    color: rgba(23, 26, 38, 1);
    font-size: 28rpx;
  }

  .registerPage_fd1_1_c0 {
    width: 34rpx;
    height: 34rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 32rpx 0rpx 0rpx;
  }

  .registerPage_fd1_1 {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0rpx 3rpx 6rpx 1rpx #F2F5FF;
    background-size: 100% auto;
    border-radius: 44rpx;
    padding: 24rpx 32rpx 24rpx 32rpx;
  }

  .registerPage_fd1_0_c0 {
    width: 148rpx;
    height: 148rpx;
    border-radius: 33rpx;
  }

  .registerPage_fd1_0 {
    margin: 78rpx 0rpx 124rpx 0rpx;
  }

  .registerPage_flex_2s {
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(80rpx + var(--window-bottom));
  }

  .registerPage_flex_2 {
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(40rpx + var(--window-bottom));
  }

  .registerPage_fd2_0_c2 {
    color: #6450EB;
    font-size: 24rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .registerPage_fd2_0_c1 {
    color: rgba(153, 153, 153, 1);
    font-size: 24rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .registerPage_noCheckfd2_0_c0_c1_c0 {
    border-radius: 24rpx 24rpx 24rpx 24rpx;
    width: 32rpx;
    height: 32rpx;
  }

  .registerPage_checkfd2_0_c0_c0_c0 {
    width: 32rpx;
    height: 32rpx;
    border-radius: 24rpx 24rpx 24rpx 24rpx;
  }

  ::v-deep .registerPage_fd2_0_c0 {
    margin: 0rpx 16rpx 0rpx 0rpx;
  }
</style>
